﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Argos.WorkflowServices;
using Argos;
using Argos.Data.Model;
using Argos.Activities.MessageDelivery;
using Argos.Scheduling;

namespace ArgosDesktop.WorkflowServices
{
	public class StorageService : StorageServiceBase
	{

		public override List<Recipient> GetRecipients(Guid targetId, AlertTypes alertType)
		{
			if (alertType == AlertTypes.Start)
				return new List<Recipient>();

			Program.EnsureAlertStorageFolder();

			Recipient r = new Recipient();
			r.Address = UserSettings.Default.AlertStorageFolder;
			r.Name = "Argos Desktop";
			r.DeliveryRoute.DeliveryActivityType = typeof(XmlFileDeliveryActivity);
			r.DeliveryRoute.DeliveryActivityProperties["MaxFileCount"] = UserSettings.Default.MaxAlertCount;
			return new List<Recipient>(new Recipient[] { r });
		}

		public override Target GetTarget(Guid targetId)
		{
			return Program.OpenTarget(targetId);
		}

		public override List<Schedule> GetTargetActiveSchedules(Guid targetId)
		{
			return new List<Schedule>(new Schedule[] { Schedule.Always });
		}

		public override List<Schedule> GetTargetBreakSchedules(Guid targetId)
		{
			return base.GetTargetBreakSchedules(targetId);
		}

		public override Test GetTargetTest(Guid targetId)
		{
			return base.GetTargetTest(targetId);
		}

		public override void StoreTestState(Guid targetId, object testState)
		{
			Program.SaveTestState(targetId, testState);
		}
	}
}
